package com.security.system.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysUser implements UserDetails {
    private Integer uid;

    private String username;

    private String password;

    private String mobile;

    private String uname;

    private List<SysRole> roles;

    /**
    * 1代表true，0代表false
    */
    private Boolean accountnonexpired;

    /**
    * 1代表true，0代表false
    */
    private Boolean accountnonlocked;

    /**
    * 1代表true，0代表false
    */
    private Boolean credentialsnonexpired;

    /**
    * 1代表true，0代表false
    */
    private Boolean enabled;



    @JsonIgnore
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return roles;
    }

    @JsonIgnore
    @Override
    public boolean isAccountNonExpired() {
        return accountnonexpired;
    }

    @JsonIgnore
    @Override
    public boolean isAccountNonLocked() {
        return accountnonlocked;
    }

    @JsonIgnore
    @Override
    public boolean isCredentialsNonExpired() {
        return credentialsnonexpired;
    }

    @JsonIgnore
    @Override
    public boolean isEnabled() {
        return enabled;
    }
}